package com.mybindview.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mybindview.R;
import java.util.List;

/**
 * Created by nbzl on 2017/2/27.
 */
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.MyViewHolder> {


    private Context context;
    private List<String> list;

    public RecyclerAdapter(Context context, List<String> list) {
        this.context = context;
        this.list = list;
    }
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.contentTxt.setText("--->"+list.get(position));
        /*holder.touimg.setImageBitmap(new BitmapUtil().imageZoom(BitmapFactory.decodeResource(context.getResources(), list.get(position))));
        holder.phone.setImageResource(list.get(position));*/
    }
    @Override
    public int getItemCount() {
        return list.size();
    }
    public class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView contentTxt;
        public MyViewHolder(View view) {
            super(view);
            contentTxt=(TextView)view.findViewById(R.id.recycle_content);
        }
    }
    public void remove(int position) {
        list.remove(position);
        notifyItemRemoved(position);
    }


}
